#!/usr/bin/env bash

# return to the default package.json and install all deps
git checkout -- package.json
npm install

test_silent () {
  npm run test &> /dev/null && echo OK || echo FAIL
}

echo -e "\n## 4.0.0"
npm install -D \
 reflect-metadata@0.1.13 \
 @nestjs/common@^4.0.0 \
 @nestjs/core@^4.0.0 \
 @nestjs/microservices@^4.0.0 \
 @nestjs/websockets@^4.0.0 \
 rxjs@^5.4.2 \
 rxjs-compat@^6.0.0 > /dev/null
test_silent

echo -e "\n## ^4.0.0"
npm install -D \
 reflect-metadata@0.1.13 \
 @nestjs/common@^4.4.0 \
 @nestjs/core@^4.4.0 \
 @nestjs/microservices@^4.4.0 \
 @nestjs/websockets@^4.4.0 \
 rxjs@^5.4.2 \
 rxjs-compat@^6.0.0 > /dev/null
test_silent

echo -e "\n## ^5.0.0"
npm install -D \
 reflect-metadata@0.1.13 \
 @nestjs/common@^5.0.0 \
 @nestjs/core@^5.0.0 \
 @nestjs/microservices@^5.0.0 \
 @nestjs/websockets@^5.0.0 \
 rxjs@^6.0.0 \
 rxjs-compat@^6.0.0 > /dev/null
test_silent

echo -e "\n## ^6.0.0"
npm install -D \
 reflect-metadata@0.1.13 \
 @nestjs/common@^6.0.0 \
 @nestjs/core@^6.0.0 \
 @nestjs/microservices@^6.0.0 \
 @nestjs/websockets@^6.0.0 \
 @nestjs/platform-express@^6.0.0 \
 rxjs@^6.0.0 \
 rxjs-compat@^6.0.0 > /dev/null
test_silent

echo -e "\n## ^7.0.0"
npm install -D \
 reflect-metadata@0.1.13 \
 @nestjs/common@^7.0.0 \
 @nestjs/core@^7.0.0 \
 @nestjs/microservices@^7.0.0 \
 @nestjs/websockets@^7.0.0 \
 @nestjs/platform-express@^7.0.0 \
 rxjs@^7.0.0 \
 rxjs-compat@latest > /dev/null
test_silent

echo -e "\n## ^8.0.0"
npm install -D \
 reflect-metadata@0.1.13 \
 @nestjs/common@^8.0.0 \
 @nestjs/core@^8.0.0 \
 @nestjs/microservices@^8.0.0 \
 @nestjs/websockets@^8.0.0 \
 @nestjs/platform-express@^8.0.0 \
 rxjs@^7.2.0 \
 rxjs-compat@latest > /dev/null
test_silent
